Draft
Conversation
…→ui cycle - Add shared/lib/selectors/keyring-utils.ts with pure keyring helpers - Add shared/lib/selectors/metamask-keyring.ts for getCurrentKeyringFromState - Implement isHardwareWallet and getHardwareWalletType in shared/lib/selectors/account.ts - Remove shared/lib/selectors index imports from ui/selectors/selectors - Regenerate circular-deps.jsonc (cycle count unchanged: 9) Made-with: Cursor
- Add TemplateRendererContext so MetaMaskTranslation does not import MetaMaskTemplateRenderer - MetaMaskTemplateRenderer provides itself via context; translation consumes it - Remove ui/components/app/** from .madgerc (no longer matches any cycle) - Cycle count: 9 -> 8 Made-with: Cursor
…basic - Add ui/selectors/metamask-state-basic.js with getAlertEnabledness, getUnconnectedAccountAlertEnabledness, getCompletedOnboarding - actions.ts imports these from metamask-state-basic instead of ducks/metamask - metamask.js re-exports from metamask-state-basic and removes duplicate definitions - Cycle count: 8 -> 7 Made-with: Cursor
- Add getPreferences and accountSupportsSmartTx to shared/lib/selectors/metamask-keyring.ts - Add selectNetworkConfigurationByChainId and selectDefaultRpcEndpointByChainId to shared/networks.ts - smart-transactions.ts imports from shared instead of ui/selectors/selectors - Add ui/pages/confirmations/** to .madgerc for remaining cycle - Remove shared/lib/selectors/** from .madgerc (no longer in any cycle) - Cycle count: 7 -> 2 Made-with: Cursor
- Extract TEMPLATED_CONFIRMATION_APPROVAL_TYPES to templates/approval-types.js - approval-types only imports from constants no store or selectors - selectors and useConfirmationNavigation import from approval-types - Remove ui/pages/confirmations/** from .madgerc - Cycle count: 2 (simplified 8-file confirmations cycle) Made-with: Cursor
…ar-deps.jsonc - Removed circular dependencies by introducing new selectors in send-ether-selectors.js and metamask-selectors-standalone.js. - Updated imports in various files to utilize the new selectors, ensuring a cleaner architecture. - Cleared the circular-deps.jsonc file as there are no longer any circular dependencies detected. Made-with: Cursor
- Removed all entries from the allowedCircularGlob array in .madgerc, reflecting the recent architectural changes that have eliminated circular dependencies in the codebase. Made-with: Cursor
- Convert template-renderer-context, approval-types, metamask-gas-selectors, metamask-selectors-standalone, metamask-state-basic, send-ether-selectors to .ts - Memoize accountsWithSendEtherInfoSelector with createSelector
Contributor
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Contributor
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations (6 files, +64 -24)
🫰 @MetaMask/core-platform (2 files, +31 -20)
🔒 @MetaMask/extension-security-team (1 files, +1 -52)
👨🔧 @dbrans (1 files, +1 -52)
👨🔧 @HowardBraham (1 files, +1 -52)
|
Contributor
Builds ready [c5bd633]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Contributor
|
@rvelaz you did it! But the tests are not all passing. |
Contributor
|
Nice work @rvelaz! Minor - maybe the names of the new files can simplified or grouped by feature? "ui/selectors/metamask-selectors-basic" and "ui/selectors/metamask-selectors-standalone" might be confusing later on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR removes all circular dependency cycles in the MetaMask extension codebase, reducing the count from 9 to 0. The changes follow the "break selector chains" and "extract shared code" strategies by introducing standalone selector modules that do not depend on the metamask duck or the rest of the selectors.
Changes
New files (TypeScript)
ui/selectors/send-ether-selectors.tsgetAddressBook,accountsWithSendEtherInfoSelector,checkNetworkAndAccountSupports1559,isEIP1559Network,isNotEIP1559Network) with no metamask/selectors dependency;accountsWithSendEtherInfoSelectormemoized viacreateSelectorui/selectors/metamask-gas-selectors.tsgetGasEstimateType,getGasFeeEstimates,getNativeCurrency) used by confirm-transaction and custom-gasui/selectors/metamask-selectors-standalone.tsgetConversionRate,getIsUnlocked,getLedgerTransportType,isAddressLedger,getCompletedOnboarding,isNotEIP1559Network) used by selectors.jsui/selectors/metamask-state-basic.tsgetAlertEnabledness,getUnconnectedAccountAlertEnabledness,getCompletedOnboarding,getIsMainnet) with no store/actions dependencyui/components/app/metamask-template-renderer/template-renderer-context.tsui/pages/confirmations/confirmation/templates/approval-types.tsTEMPLATED_CONFIRMATION_APPROVAL_TYPESconstant (breaks selectors → templates → actions cycle)Modified files
ui/ducks/metamask/metamask.js– Imports fromsend-ether-selectorsandmetamask-state-basicinstead ofselectors; removedisEIP1559Network,getAlertEnabledness,getUnconnectedAccountAlertEnabledness,getCompletedOnboarding(moved to extracted modules)ui/selectors/confirm-transaction.js– Imports gas selectors frommetamask-gas-selectorsinstead of metamaskui/selectors/custom-gas.js– Imports frommetamask-gas-selectors,metamask-state-basic, andsend-ether-selectorsinstead of metamask/selectorsui/selectors/selectors.js– Imports frommetamask-selectors-standalone,send-ether-selectors,metamask-state-basic, andapproval-types; re-exportsgetIsMainnet,getAddressBook,accountsWithSendEtherInfoSelector,checkNetworkAndAccountSupports1559ui/store/actions.ts– Imports frommetamask-state-basicinstead of metamask duck.madgerc– SetallowedCircularGlobto[](no remaining cycles)Other prior commits (included in branch)
keyring-utils.ts,metamask-keyring.ts)TemplateRendererContextmetamask-state-basic.tsapproval-types.ts